package com.gms.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.gms.domain.UserInfo;
import com.gms.service.UserInfoService;
import com.opensymphony.xwork2.ActionSupport;

public class RegisterAction extends ActionSupport implements SessionAware{
	private UserInfo userInfo;
	private UserInfoService userInfoService;
	private String[] Aihao;
	private Map<String, Object> session;
	
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	public String[] getAihao() {
		return Aihao;
	}

	public void setAihao(String[] aihao) {
		Aihao = aihao;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println("in this");
		String aihao = "";
		for (int i = 0; i < Aihao.length; i++) {
			aihao += "_" + Aihao[i];
		}
		userInfo.setHobby(aihao);
		userInfoService.register(userInfo);
		session.put("currUser", userInfo);
		return "success";
	}

	@Override
	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub
		this.session = session;
	}

}
